home *** CD-ROM | disk | FTP | other *** search
- ' SALES.BAS
- ' This program tracks the sales of soda over a given number of months.
-
- CLS
-
- PRINT "** Soda sales tracking program **"
- PRINT
- DO
- INPUT "How many brands of soda do you sell? ", brands%
- LOOP WHILE (brands% < 1)
- DO
- INPUT "How many months would you like to record (1-12)? ", months%
- LOOP WHILE (months% < 1) OR (months% > 12)
- PRINT
-
- OPTION BASE 1 ' set first array element at 1
- DIM sodaSales%(brands%, months%) ' dimension soda sales array
- DIM brandNames$(brands%) ' dimension brand name array
-
- ' get names of soda brands sold
-
- PRINT "Enter the"; brands%; "brands of soda you sell"
- PRINT
- FOR i% = 1 TO brands%
- INPUT "Brand name: ", brandNames$(i%)
- NEXT i%
-
- ' get soda sales for each month
-
- PRINT
- PRINT "Enter soda sales in cases"
- PRINT
-
- FOR i% = 1 TO brands% ' for each brand of soda...
- PRINT "** "; brandNames$(i%); " **"
- PRINT ' print name of brand
- FOR j% = 1 TO months% ' for each month...
- READ mo$ ' read month name from DATA list
- PRINT " "; mo$; ' print month name and prompt for input
- INPUT ": ", sodaSales%(i%, j%) ' store input in array
- NEXT j%
- PRINT
- RESTORE ' rewind DATA list to first month
- NEXT i%
-
- ' print out soda sales table
-
- CLS
-
- PRINT "Soda sales in cases for"; months%; "months"
- PRINT
- PRINT "--------------------------------------------------------------"
- PRINT "Brand/Month ";
-
- FOR i% = 1 TO months%
- PRINT " ";
- READ mo$ ' read month name from DATA list
- PRINT mo$; ' print month names across top of table
- NEXT i%
-
- PRINT
- PRINT "--------------------------------------------------------------"
-
- ' templates for PRINT USING
-
- nameTmp$ = "\ \" ' for brand name (up to 12 digits)
- salesTmp$ = " ###" ' for cases sold (up to 3 digits)
-
- FOR i% = 1 TO brands% ' fills in the table
- PRINT USING nameTmp$; brandNames$(i%);
- FOR j% = 1 TO months%
- PRINT USING salesTmp$; sodaSales%(i%, j%);
- NEXT j%
- PRINT
- NEXT i%
-
- PRINT "--------------------------------------------------------------"
-
- ' data for READ statements above
-
- DATA Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
-
-